/******************************************
@Description:商户审核通过后-统计银行/保险商户数量
@Time : 2020/12/28 11:22
@Author :lixiaojun
交换机=bus.auditbus

*******************************************/
package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/financial"
	"github.com/streadway/amqp"
	"strconv"
)

func main() {
	rpcFinancial:=new(financial.Bank).Init()
	defer rpcFinancial.Close()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("financial.log.addBankOrInsuranceBusNumQue"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("financial.queue.addBankOrInsuranceBusNum"), func(msg amqp.Delivery) {
		busId,err := strconv.Atoi(string(msg.Body))
		if err != nil {
			return
		}
		var reply bool
		if err=rpcFinancial.StatisticsBankOrInsuranceBusNum(context.Background(),&busId,&reply);err!=nil{
			utils.Logerr.Printf("商户审核通过后-统计银行/保险商户数量任务执行失败，busId:%v，错误信息：%s\n",busId,err.Error())
		}
	})
	if err != nil {
		utils.Logerr.Printf("商户审核通过后-统计银行/保险商户数量任务执行错误，错误信息：%s\n",err.Error())
	}
}

